# -*- coding: utf-8 -*- 
# 作者:飞虎
# 开发时间:2022/5/16 20:15
from PyQt5.Qt import *


class Window(QWidget):
	def __init__(self):
		super().__init__()
		self.setWindowTitle('布局管理的学习')
		self.resize(500, 500)
		self.setup_ui()

	def setup_ui(self):
		# 创建三个子控件
		label1= QLabel('标签1')
		label1.setStyleSheet('background-color:cyan')
		label2= QLabel('标签2')
		label2.setStyleSheet('background-color:yellow')
		label3= QLabel('标签3')
		label3.setStyleSheet('background-color:red')

		# label_width = self.width()
		# label_height=int(self.height()/3)
		# label1.resize(label_width,label_height)
		# label2.resize(label_width,label_height)
		# label3.resize(label_width,label_height)
		# label1.move(0,0)
		# label2.move(0,label1.height())
		# label3.move(0,label2.y()+label2.height())
		#
		# # label2.hide()
		# timer = QTimer(self)
		# timer.timeout.connect(lambda :label1.setText(label1.text()+'itlike\n'))
		# timer.start(1000)

		# 布局管理的实现方式
		v_layout = QHBoxLayout()
		v_layout.addWidget(label1)
		v_layout.addWidget(label2)
		v_layout.addWidget(label3)

		v_layout.setContentsMargins(20,30,40,50)
		v_layout.setSpacing(60)


		self.setLayout(v_layout)
		self.setLayoutDirection(Qt.RightToLeft)
		# label2.hide()

		print(self.children())


if __name__ == '__main__':
	import sys

	app = QApplication(sys.argv)
	window = Window()
	window.show()
	sys.exit(app.exec_())